package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c1= new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add("php");
        System.out.println("c1"+c1);//[java, c++, php]

        Collection c2= new ArrayList();
        c2.add("java");
        c2.add("ios");
        c2.add("android");
        System.out.println("c2"+c2);//[java, ios, android]

        c1.addAll(c2);//将c2中的元素全部添加到c1中
        System.out.println("c1"+c1);//[java, c++, php, java, ios, android]
        System.out.println("c2"+c2);//[java, ios, android]

        Collection c3=new ArrayList();
        c3.add("c++");
        c3.add("android");
        c3.add("php");
        System.out.println("c3"+c3);

        boolean contains=c1.containsAll(c3);
        System.out.println("c1是否包含c3:"+contains);

//        c1.retainAll(c3); 取交集
//        System.out.println("c1"+c1);//[c++, php]
//        System.out.println("c3"+c3);//[c++, android, php]

        //删交集
         c1.removeAll(c3);
         System.out.println("c1"+c1);
         System.out.println("c3"+c3);



    }
}
